<extend name="Base/common"/>
<block name="body">
<style type="text/css">
.div-one{ margin: auto;width: 50%; margin-top: 50px;}
.div-one table tr td input{ margin-left: 50px; }
.div-one table tr td select{ margin-left: 50px; }
.div-one table tr{ 	display:block; margin:10px; }
#upload_picture_imgs{ background-color: red; }
.userverify{ width: 60%; height: 70%;}
</style>
<form action="__SELF__" class="form-horizontal" id="mac" method="post" enctype="multipart/form-data">
<div id="TopTranslate">
			<header><a href="{:U('index/index')}" class="back"><img src="__IMG__/images/back_03.png"/></a>二维码</header>
			<div class="Translate">
			<!-- <h1>上传二维码</h1> -->
			<div style="text-align: center;">
			<!-- 11111 -->
				<script type="text/javascript">
				 	$(function() {
				  $("#pic").click(function () {
				    $("#upload").click();               //隐藏了input:file样式后，点击头像就可以本地上传
				     $("#upload").on("change",function(){
				       var objUrl = getObjectURL(this.files[0]) ;  //获取图片的路径，该路径不是图片在本地的路径
				       if (objUrl) {
				         $("#pic").attr("src", objUrl) ;      //将图片路径存入src中，显示出图片
				       }
				    });
				  });
				});
				//建立一個可存取到該file的url
				function getObjectURL(file) {
				  var url = null ;
				  if (window.createObjectURL!=undefined) { // basic
				    url = window.createObjectURL(file) ;
				  } else if (window.URL!=undefined) { // mozilla(firefox)
				    url = window.URL.createObjectURL(file) ;
				  } else if (window.webkitURL!=undefined) { // webkit or chrome
				    url = window.webkitURL.createObjectURL(file) ;
				  }
				  return url ;
				}
				// <if condition="$data['qr_code'] neq ''">.{$data.qr_code|get_cover=###,'path'}<else/>__IMG__/images/scewm_03.jpg</if>
				 </script>
				<img id="pic"  src="<if condition="$pics neq ''">__ROOT__{$pics|get_cover=###,'path'}<else/>__IMG__/images/scewm_03.jpg</if>" alt="点击上传图片">
				<input id="upload" name="qr_code" accept="image/*" type="file" style="display: none"/>
				<style>
				#pic{
				     width: 250px;
				    /*border-radius: 50%;*/
				    margin: 20px auto;
				    cursor: pointer;
				    height: 250px;
				    border: 1px solid;
				   }
				   #upload{
				   	border: none;
				   }

				 </style>
				<!-- 11111 -->
				<br/>
				<span>请选择二维码</span>
			</div>

			</div>
			<input type="button" id="btn" class="ajax-file" name="" value="上传照片" />
			</form>
		</div>
		<script type="text/javascript">
		//ajax自写跳转
		$('.ajax-file').click(function(){
			var url= $('#mac').attr('action');
			var fd = new FormData($("#mac")[0]);
			$.ajax({
				  url: url,
				  type: "POST",
				  data: fd,
				  processData: false,  // 告诉jQuery不要去处理发送的数据
				  contentType: false,  // 告诉jQuery不要去设置Content-Type请求头
				  success: function(data){
				  	var index =layer.alert(data.info,function(){
						  		location.href="{:U('Index/index')}";
						  	});
				  		}
				});
			})
	</script>
</block>